﻿"""User schemas."""

from __future__ import annotations

from typing import Literal, Optional

from pydantic import EmailStr, Field

from ..schemas.base import ORMBase, TimestampModel

UserRole = Literal["admin", "project_manager", "consultant", "client"]
DEFAULT_ROLE: UserRole = "consultant"


class UserBase(ORMBase):
    email: EmailStr
    full_name: Optional[str] = None
    is_active: bool = True
    role: UserRole = DEFAULT_ROLE


class UserCreate(UserBase):
    password: str = Field(min_length=8, max_length=128)
    role: UserRole = DEFAULT_ROLE


class UserUpdate(ORMBase):
    full_name: Optional[str] = Field(default=None, max_length=255)
    password: Optional[str] = Field(default=None, min_length=8, max_length=128)
    is_active: Optional[bool] = None
    is_admin: Optional[bool] = None
    role: Optional[UserRole] = None


class UserOut(UserBase, TimestampModel):
    id: int
    is_admin: bool = False
